import java.util.ArrayList;
import java.util.List;





public class EXTTable {
	
	//store symbols in the EXT operands.
	private static List<String> extTab = new ArrayList<String>();
	
	
	public static void add(String str,Integer lineNum) throws AssembleException {
		if(extTab.contains(str)) {
			throw new AssembleException(15,lineNum,str);
		}else {
			extTab.add(str);
		}
	}
	
	
	//convert each element in the table to the object code format.
	/*public static String toObj() {
		int len = extTab.size();
		StringBuilder objString = new StringBuilder();
		objString.append("");
		for(int i =0;i<len;i++) {
			objString.append("V"+Utilities.intToHex(5*i)+extTab.get(i)+"\n");
		}
		return objString.toString();
	}*/
	
	public static boolean hasSymb(String str) {
		return extTab.contains(str);
	}
	
	public static Integer getAddr(String str) {
		return extTab.indexOf(str)*5;
	}
}
